'''
# Coding:utf-8
# Project: iiop
# Author: rtf
# Time: 2021-03-16 15:35:56
# FileName: docxtpl_process.py
# Software: PyCharm
'''


from docxtpl import DocxTemplate
from func.root_path import get_path


async def save_docx(docx_type, context, save_path, docx_path=None):
    if docx_path:
        docx_tpl = docx_path
    else:
        if docx_type == "NON_PURCHASE":
            docx_tpl = f"{get_path()}/docx_template/NON_PURCHASE_tpl.docx"
        elif docx_type == "PURCHASE_CATEGORY":
            docx_tpl = f"{get_path()}/docx_template/PURCHASE_CATEGORY_tpl.docx"
        else:
            docx_tpl = f"{get_path()}/docx_template/calculation_report_tpl.docx"
    tpl = DocxTemplate(docx_tpl)

    tpl.render(context)
    tpl.save(save_path)


# 测算结果摘要
summary = {
    "project_name": "项目名称",
    "calculation_result": {
          "cdf_workload": "咨询设计费(工作量（人天）)", "cdf_labor_rate": "咨询设计费(人工费率（万元）)", "cdf_cost": "咨询设计费(费用（万元）)",
          "sfd_workload": "系统功能开发(工作量（人天）)", "sfd_labor_rate": "系统功能开发(人工费率（万元）)", "sfd_cost": "系统功能开发(费用（万元）)",
          "sid_workload": "系统集成开发(工作量（人天）)", "sid_labor_rate": "系统集成开发(人工费率（万元）)", "sid_cost": "系统集成开发(费用（万元）)",
          "si_workload": "系统实施(工作量（人天）)", "si_labor_rate": "系统实施(人工费率（万元）)", "si_cost": "系统实施(费用（万元）)",
          "sii_workload": "系统集成实施(工作量（人天）)", "sii_labor_rate": "系统集成实施(人工费率（万元）)", "sii_cost": "系统集成实施(费用（万元）)",
          "boe_workload": "业务运营费(工作量（人天）)", "boe_labor_rate": "业务运营费(人工费率（万元）)", "boe_cost": "业务运营费(费用（万元）)",
          "dprd_workload": "数据产品（应用）研发(工作量（人天）)", "dprd_labor_rate": "数据产品（应用）研发(人工费率（万元）)", "dprd_cost": "数据产品（应用）研发(费用（万元）)",
          "dsiccq_workload": "数据标准化、盘点、目录构建、质量治理等(工作量（人天）)", "dsiccq_labor_rate": "数据标准化、盘点、目录构建、质量治理等(人工费率（万元）)", "dsiccq_cost": "数据标准化、盘点、目录构建、质量治理等   (费用（万元）)",
          "duddi_workload": "数据接入、上传、下发、数据产品（应用）实施(工作量（人天）)", "duddi_labor_rate": "数据接入、上传、下发、数据产品（应用）实施(人工费率（万元）)", "duddi_cost": "数据接入、上传、下发、数据产品（应用）实施(费用（万元）)",
          "other_cost": "其它费用(费用（万元）)",
          "total": "总计"
    }
}

# 前言
preface = {"commissioned_project": "委托项目", "references": "见..."}


# 测算目的
purpose = {"purpose_item": "xxxxxx"}

# 投资分析
investment_analysis = {
           "in_basis": "本投资测算根据", "in_item": "子项", "in_item_num": "子项数量", "in_total": "总投资",
           "calculation_result": {
               "in_cdf_workload": "咨询设计费(工作量（人天）)", "in_cdf_labor_rate": "咨询设计费(人工费率（万元）)", "in_cdf_cost": "咨询设计费(费用（万元）)",
               "in_sfd_workload": "系统功能开发(工作量（人天）)", "in_sfd_labor_rate": "系统功能开发(人工费率（万元）)", "in_sfd_cost": "系统功能开发(费用（万元）)",
               "in_sid_workload": "系统集成开发(工作量（人天）)", "in_sid_labor_rate": "系统集成开发(人工费率（万元）)", "in_sid_cost": "系统集成开发(费用（万元）)",
               "in_si_workload": "系统实施(工作量（人天）)", "in_si_labor_rate": "系统实施(人工费率（万元）)", "in_si_cost": "系统实施(费用（万元）)",
               "in_sii_workload": "系统集成实施(工作量（人天）)", "in_sii_labor_rate": "系统集成实施(人工费率（万元）)", "in_sii_cost": "系统集成实施(费用（万元）)",
               "in_boe_workload": "业务运营费(工作量（人天）)", "in_boe_labor_rate": "业务运营费(人工费率（万元）)", "in_boe_cost": "业务运营费(费用（万元）)",
               "in_dprd_workload": "数据产品（应用）研发(工作量（人天）)", "in_dprd_labor_rate": "数据产品（应用）研发(人工费率（万元）)", "in_dprd_cost": "数据产品（应用）研发(费用（万元）)",
               "in_dsiccq_workload": "数据标准化、盘点、目录构建、质量治理等(工作量（人天）)", "in_dsiccq_labor_rate": "数据标准化、盘点、目录构建、质量治理等(人工费率（万元）)", "in_dsiccq_cost": "数据标准化、盘点、目录构建、质量治理等   (费用（万元）)",
               "in_duddi_workload": "数据接入、上传、下发、数据产品（应用）实施(工作量（人天）)", "in_duddi_labor_rate": "数据接入、上传、下发、数据产品（应用）实施(人工费率（万元）)", "in_duddi_cost": "数据接入、上传、下发、数据产品（应用）实施(费用（万元）)",
               "in_other_cost": "其它费用(费用（万元）)",
               "in_total": "总计"
           },
           "in_items": [
                {"no": 1, "system_name": "子项1", "consulting_design": "咨询设计", "sfd": " 系统功能开发", "sid": "系统集成开发", "si": "系统实施",
                     "sii": "系统集成实施", "bo": "业务运营", "de": "数据工程", "subtotal": "小计"},
                {"no": 2, "system_name": "子项2", "consulting_design": "咨询设计", "sfd": " 系统功能开发", "sid": "系统集成开发", "si": "系统实施",
                     "sii": "系统集成实施", "bo": "业务运营", "de": "数据工程", "subtotal": "小计"},
                {"no": 3, "system_name": "子项3", "consulting_design": "咨询设计", "sfd": " 系统功能开发", "sid": "系统集成开发", "si": "系统实施",
                     "sii": "系统集成实施", "bo": "业务运营", "de": "数据工程", "subtotal": "小计"}
           ],
           "in_other_consulting_designcost": "小计",
           "analysis_table_total": "合计"
       }

# 其它费用
other_cost = {"other_cost_fs": "可行性研究费", "other_cost_third": "第三方测试费",
              "other_cost_legal_person": "项目法人管理费", "other_cost_acceptance": "项目验收费",
              "other_cost_property": "知识产权费", "other_cost_total": "合计"}


# 子项
items = {"items": [
        {
            "item_name": "子项1",
            "consulting_design": {
                  "cd_item": "咨询设计任务1、询设计任务2",
                  "cd_man_day": "人天",
                  "cd_total": "合计",
                  "cd_split": "咨询设计任务1，预估投入  2  人天；咨询设计任务2，预估投入   2  人天。",
                  "cd_total_table": [
                      {"no": 1, "work_task": "咨询设计任务1", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"},
                      {"no": 2, "work_task": "咨询设计任务2", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"}
                  ],
                  "cd_total_table_final_workload": "最终工作量（人天）合计",
                  "cd_total_table_cost": "费用（万元）合计",
                  "cd_details_table": [
                      {
                           "work_task": "咨询设计任务1", "workload_base": "工作量基数（人天）",
                           "initial_workload": "初始工作量（人天）", "final_workload": "最终工作量（人天）",
                           "labor_rate": "人工费率（万元/天）", "cost": "费用（万元）", "if_business_type": "影响因子业务类型",
                           "if_influence_level": "影响因子影响程度", "if_succession": "影响因子成果继承",
                           "if_design_depth": "影响因子设计深度", "if_scheme_verification": "影响因子方案验证难度",
                           "if_new_technology": "影响因子新技术应用", "total": "合计"
                      },
                      {
                           "work_task": "咨询设计任务2", "workload_base": "工作量基数（人天）",
                           "initial_workload": "初始工作量（人天）", "final_workload": "最终工作量（人天）",
                           "labor_rate": "人工费率（万元/天）", "cost": "费用（万元）", "if_business_type": "影响因子业务类型",
                           "if_influence_level": "影响因子影响程度", "if_succession": "影响因子成果继承",
                           "if_design_depth": "影响因子设计深度", "if_scheme_verification": "影响因子方案验证难度",
                           "if_new_technology": "影响因子新技术应用", "total": "合计"
                      }
                  ]
             },
            "system_functions": {
                 "sf_item": "需求1、需求2、需求3",
                 "sf_man_day": "人天",
                 "sf_total": "合计",
                 "sf_calculation_table": [
                      {"no": 1, "need_name": "需求1", "min_functional_unit": "最小功能单元"},
                      {"no": 2, "need_name": "需求2", "min_functional_unit": "最小功能单元"}
                 ],
                 "sf_calculation_table_total": "初始规模测算结果合计",
                 "sf_detail_table":  {
                           "sf_min_functional_unit": "规模初始测算结果（最小功能单元）",
                           "sf_productivity": "生产率（人天/最小功能单元）", "sf_work_scope": "工作范围",
                           "sf_initial_workload": "初始工作量（人天）", "sf_final_workload": "最终工作量（人天）",
                           "sf_labor_rate": "人工费率（万元/天）", "sf_cost": "系统功能开发费用（万元）",
                           "sf_if_alc": "架构层次复杂度", "sf_if_east": "企业中台应用情况", "sf_if_system_integration": "系统集成情况",
                           "sf_if_application_type": "应用类型", "sf_if_drl": "灾备等级", "sf_if_new_technology": "新技术应用",
                           "sf_if_micro_application": "微应用", "sf_if_model_algorithm": "模型算法",
                           "sf_if_business_complexity": "业务自身复杂度", "sf_if_user_type": "用户类型",
                           "sf_if_cross_business_caliber": "跨业务口径", "sf_if_business_maturity": "业务成熟度",
                           "sf_if_business_type": "业务类型", "sf_if_pdn": "个性化定制开发需要",
                           "sf_if_uia": "用户交互调整情况", "sf_if_original_design": "原创性设计",
                           "sf_if_active_user": "活跃用户", "sf_if_max_concurrent_users": "最大并发用户",
                           "sf_if_bir": "业务即时性要求", "sf_if_har": "高可用要求",
                           "sf_if_data_size": "数据规模", "sf_if_plats": "感知层接入终端规模",
                           "sf_if_spr": "安全防护要求", "sf_if_spl": "安全防护等级",
                           "sf_if_scd": "系统构建难度", "sf_if_user_activity": "用户活跃度",
                           "sf_if_total": "合计"
                  }
             },
            "system_integration": {
                "si_item": "系统1、系统2、系统3",
                "si_item_num": 3,
                "si_man_day": "人天",
                "si_total": "合计",
                "si_table": [
                      {"no": 1, "system_name": "系统1", "local_man_day": "本端系统集成开发工作量（人天）", "peer_man_day": "对端系统集成开发工作量（人天）"},
                      {"no": 2, "system_name": "系统2", "local_man_day": "本端系统集成开发工作量（人天）", "peer_man_day": "对端系统集成开发工作量（人天）"},
                      {"no": 3, "system_name": "系统3", "local_man_day": "本端系统集成开发工作量（人天）", "peer_man_day": "对端系统集成开发工作量（人天）"}
                 ],
                "si_final_workload": "最终工作量（人天）",
                "si_labor_rate": "人工费率（万元/天）",
                "si_cost": "系统功能开发费用（万元）"
            },
            "system_implementation": {
                "sii_item": "实施工作项1、实施工作项2",
                "sii_item_num": 3,
                "sii_man_day": "人天",
                "sii_total": "合计",
                "sii_table": [
                    {"no": 1, "sii_name": "实施工作项1", "workload": "工作量（人天）", "cost": "费用（万元）"},
                    {"no": 2, "sii_name": "实施工作项2", "workload": "工作量（人天）", "cost": "费用（万元）"},
                    {"no": 3, "sii_name": "实施工作项3", "workload": "工作量（人天）", "cost": "费用（万元）"}
                ],
                "sii_table_workload_total": "工作量合计",
                "sii_table_cost_total": "费用合计",
                "sii_details_table": [
                    {
                         "level": "一级部署",
                         "description": "实施工作项1按一级 部署方式....",
                         "sii_name": "实施工作项1",
                         "sii_first_workload": "一级部署（总部侧）工作量基数（人天）",
                         "sii_workload": "工作量基数（分部、省公司和直属单位）（人天）",
                         "sii_scope": "实施范围（除总部外）",
                         "sii_workload_total": "初始工作量合计（人天）",
                         "sii_work_scope": "实施工作范围",
                         "sii_application_type": "应用类型",
                         "sii_business_maturity": "业务成熟度",
                         "sii_drl": "灾备等级",
                         "sii_new_technology": "新技术应用",
                         "sii_plats": "感知层业务支撑",
                         "sii_adaptive_adjustment": "适应性调整",
                         "sii_cpc": "跨专业采集",
                         "sii_nft": "非功能性调优",
                         "sii_osc_num": "现场采集数量",
                         "sii_co": "采集对象",
                         "sii_spr": "安全防护要求",
                         "sii_spl": "安全防护等级",
                         "sii_scd": "系统构建难度",
                         "sii_user_active": "用户活跃度",
                         "sii_total": "合计",
                         "sii_work_content": "工作内容",
                         "sii_final_workload": "最终工作量（人天）",
                         "sii_labor_rate": "人工费率（万元/天）",
                         "sii_cost": "系统实施费用（万元）"
                     },
                    {
                         "level": "二级部署",
                         "description": "实施工作项2按二级 部署方式....",
                         "sii_name": "实施工作项1",
                         "sii_second_workload": "二级部署工作量基数（人天））",
                         "sii_scope": "实施范围（除总部外）",
                         "sii_workload_total": "初始工作量合计（人天）",
                         "sii_work_scope": "实施工作范围",
                         "sii_application_type": "应用类型",
                         "sii_business_maturity": "业务成熟度",
                         "sii_drl": "灾备等级",
                         "sii_new_technology": "新技术应用",
                         "sii_plats": "感知层业务支撑",
                         "sii_adaptive_adjustment": "适应性调整",
                         "sii_cpc": "跨专业采集",
                         "sii_nft": "非功能性调优",
                         "sii_osc_num": "现场采集数量",
                         "sii_co": "采集对象",
                         "sii_spr": "安全防护要求",
                         "sii_spl": "安全防护等级",
                         "sii_scd": "系统构建难度",
                         "sii_user_active": "用户活跃度",
                         "sii_total": "合计",
                         "sii_work_content": "工作内容",
                         "sii_final_workload": "最终工作量（人天）",
                         "sii_labor_rate": "人工费率（万元/天）",
                         "sii_cost": "系统实施费用（万元）"
                     }
                ]
            },
            "system_integration_implementation": {
                "si_impl_item": "系统1、系统2、系统3",
                "si_impl_item_num": 3,
                "si_impl_man_day": "人天",
                "si_impl_total": "合计",
                "si_impl_table": [
                    {"no": 1, "system_name": "系统1", "local_man_day": "本端系统集成实施工作量（人天）", "peer_man_day": "对端系统集成实施工作量（人天）"},
                    {"no": 2, "system_name": "系统2", "local_man_day": "本端系统集成实施工作量（人天）", "peer_man_day": "对端系统集成实施工作量（人天）"},
                    {"no": 3, "system_name": "系统3", "local_man_day": "本端系统集成实施工作量（人天）", "peer_man_day": "对端系统集成实施工作量（人天）"}
                ],
                "si_impl_final_workload": "最终工作量（人天）",
                "si_impl_labor_rate": "人工费率（万元/天）",
                "si_impl_cost": "系统功能实施费用（万元）"
            },
            "business_operations": {
                "bo_item": "工作1、工作2",
                "bo_man_day": "人天",
                "bo_total": "合计",
                "bo_table": [
                    {"no": 1, "work_task": "工作任务1", "work_type": "信息支撑及其它", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"},
                    {"no": 2, "work_task": "工作任务2", "work_type": "性能优化", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"}
                ],
                "bo_table_work_total": "最终工作量（人天）合计",
                "bo_table_cost_total": "费用（万元）合计",
                "bo_details_table": [
                    {
                        "bo_work_type": "信息支撑及其它",
                        "bo_workload": "初始工作量（人天）",
                        "bo_scope": "运营范围",
                        "bo_impact_factor": 1,
                        "bo_final_workload": "最终工作量（人天）",
                        "bo_labor_rate": "人工费率（万元/天）",
                        "bo_cost": "业务运营费用（万元）"
                    },
                    {
                        "bo_work_type": "性能优化",
                        "bo_workload": "工作量基数（人天）",
                        "bo_scope": "运营范围",
                        "bo_alc": "架构层次复杂度",
                        "bo_savc": "系统架构版本变化情况",
                        "bo_oscd": "现场协调难度",
                        "bo_oc": "运营规模",
                        "bo_total": "合计",
                        "bo_final_workload": "最终工作量（人天）",
                        "bo_labor_rate": "人工费率（万元/天）",
                        "bo_cost": "业务运营费用（万元）"
                    }
                ]
            },
            "data_engineering": {
                "de_item": "工作1、工作2",
                "de_man_day": "人天",
                "de_total": "合计",
                "de_table": [
                    {"no": 1, "work_task": "工作任务1", "work_type": "信息支撑及其它", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"},
                    {"no": 2, "work_task": "工作任务2", "work_type": "性能优化", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"}
                ],
                "de_table_work_total": "最终工作量（人天）合计",
                "de_table_cost_total": "费用（万元）合计",
                "de_details_table": [
                    {
                        "de_work_task": "工作任务1",
                        "de_work_type": "信息支撑及其它",
                        "de_workload": "工作量基数（人天）",
                        "de_first_num": "一级部署系统数量",
                        "de_second_num": "二级部署系统数量",
                        "de_initial_workload": "初始工作量（人天）",
                        "de_dss": "数据表规模",
                        "de_dtc": "数据类型复杂度",
                        "de_system_type": "系统类型",
                        "de_ambc": "跨多业务口径",
                        "de_pre_results": "前置成果",
                        "de_project_scale": "工程规模",
                        "de_total": "合计",
                        "de_final_workload": "最终工作量（人天）",
                        "de_labor_rate": "人工费率（万元/天）",
                        "de_cost": "业务运营费用（万元）"
                    },
                    {
                        "de_work_task": "工作任务2",
                        "de_work_type": "性能优化",
                        "de_workload": "工作量基数（人天）",
                        "de_first_num": "一级部署系统数量",
                        "de_second_num": "二级部署系统数量",
                        "de_initial_workload": "初始工作量（人天）",
                        "de_ac": "算法复杂度 ",
                        "de_dss": "数据表规模",
                        "de_ambc": "跨多业务口径",
                        "de_dgc": "数据获取复杂度",
                        "de_aef": "应用执行频次",
                        "de_project_scale": "工程规模",
                        "de_fs": "对外服务",
                        "de_lsv": "大屏可视化",
                        "de_final_workload": "最终工作量（人天）",
                        "de_labor_rate": "人工费率（万元/天）",
                        "de_cost": "业务运营费用（万元）"
                    }
                ]
            }
        },
        {
            "item_name": "子项2",
            "consulting_design": {
                "cd_item": "咨询设计任务1、询设计任务2",
                "cd_man_day": "人天",
                "cd_total": "合计",
                "cd_split": "咨询设计任务1，预估投入  2  人天；咨询设计任务2，预估投入   2  人天。",
                "cd_total_table": [
                    {"no": 1, "work_task": "咨询设计任务1", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"},
                    {"no": 2, "work_task": "咨询设计任务2", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"}
                ],
                "cd_total_table_final_workload": "最终工作量（人天）合计",
                "cd_total_table_cost": "费用（万元）合计",
                "cd_details_table": [
                    {
                        "work_task": "咨询设计任务1", "workload_base": "工作量基数（人天）",
                        "initial_workload": "初始工作量（人天）", "final_workload": "最终工作量（人天）",
                        "labor_rate": "人工费率（万元/天）", "cost": "费用（万元）", "if_business_type": "影响因子业务类型",
                        "if_influence_level": "影响因子影响程度", "if_succession": "影响因子成果继承",
                        "if_design_depth": "影响因子设计深度", "if_scheme_verification": "影响因子方案验证难度",
                        "if_new_technology": "影响因子新技术应用", "total": "合计"
                    },
                    {
                        "work_task": "咨询设计任务2", "workload_base": "工作量基数（人天）",
                        "initial_workload": "初始工作量（人天）", "final_workload": "最终工作量（人天）",
                        "labor_rate": "人工费率（万元/天）", "cost": "费用（万元）", "if_business_type": "影响因子业务类型",
                        "if_influence_level": "影响因子影响程度", "if_succession": "影响因子成果继承",
                        "if_design_depth": "影响因子设计深度", "if_scheme_verification": "影响因子方案验证难度",
                        "if_new_technology": "影响因子新技术应用", "total": "合计"
                    }
                ]
            },
            "system_functions": {
                "sf_item": "需求1、需求2、需求3",
                "sf_man_day": "人天",
                "sf_total": "合计",
                "sf_calculation_table": [
                    {"no": 1, "need_name": "需求1", "min_functional_unit": "最小功能单元"},
                    {"no": 2, "need_name": "需求2", "min_functional_unit": "最小功能单元"}
                ],
                "sf_calculation_table_total": "初始规模测算结果合计",
                "sf_detail_table": {
                    "sf_min_functional_unit": "规模初始测算结果（最小功能单元）",
                    "sf_productivity": "生产率（人天/最小功能单元）", "sf_work_scope": "工作范围",
                    "sf_initial_workload": "初始工作量（人天）", "sf_final_workload": "最终工作量（人天）",
                    "sf_labor_rate": "人工费率（万元/天）", "sf_cost": "系统功能开发费用（万元）",
                    "sf_if_alc": "架构层次复杂度", "sf_if_east": "企业中台应用情况", "sf_if_system_integration": "系统集成情况",
                    "sf_if_application_type": "应用类型", "sf_if_drl": "灾备等级", "sf_if_new_technology": "新技术应用",
                    "sf_if_micro_application": "微应用", "sf_if_model_algorithm": "模型算法",
                    "sf_if_business_complexity": "业务自身复杂度", "sf_if_user_type": "用户类型",
                    "sf_if_cross_business_caliber": "跨业务口径", "sf_if_business_maturity": "业务成熟度",
                    "sf_if_business_type": "业务类型", "sf_if_pdn": "个性化定制开发需要",
                    "sf_if_uia": "用户交互调整情况", "sf_if_original_design": "原创性设计",
                    "sf_if_active_user": "活跃用户", "sf_if_max_concurrent_users": "最大并发用户",
                    "sf_if_bir": "业务即时性要求", "sf_if_har": "高可用要求",
                    "sf_if_data_size": "数据规模", "sf_if_plats": "感知层接入终端规模",
                    "sf_if_spr": "安全防护要求", "sf_if_spl": "安全防护等级",
                    "sf_if_scd": "系统构建难度", "sf_if_user_activity": "用户活跃度",
                    "sf_if_total": "合计"
                }
            },
            "system_integration": {
                "si_item": "系统1、系统2、系统3",
                "si_item_num": 3,
                "si_man_day": "人天",
                "si_total": "合计",
                "si_table": [
                    {"no": 1, "system_name": "系统1", "local_man_day": "本端系统集成开发工作量（人天）", "peer_man_day": "对端系统集成开发工作量（人天）"},
                    {"no": 2, "system_name": "系统2", "local_man_day": "本端系统集成开发工作量（人天）", "peer_man_day": "对端系统集成开发工作量（人天）"},
                    {"no": 3, "system_name": "系统3", "local_man_day": "本端系统集成开发工作量（人天）", "peer_man_day": "对端系统集成开发工作量（人天）"}
                ],
                "si_final_workload": "最终工作量（人天）",
                "si_labor_rate": "人工费率（万元/天）",
                "si_cost": "系统功能开发费用（万元）"
            },
            "system_implementation": {
                "sii_item": "实施工作项1、实施工作项2",
                "sii_item_num": 3,
                "sii_man_day": "人天",
                "sii_total": "合计",
                "sii_table": [
                    {"no": 1, "sii_name": "实施工作项1", "workload": "工作量（人天）", "cost": "费用（万元）"},
                    {"no": 2, "sii_name": "实施工作项2", "workload": "工作量（人天）", "cost": "费用（万元）"},
                    {"no": 3, "sii_name": "实施工作项3", "workload": "工作量（人天）", "cost": "费用（万元）"}
                ],
                "sii_table_workload_total": "工作量合计",
                "sii_table_cost_total": "费用合计",
                "sii_details_table": [
                    {
                        "level": "一级部署",
                        "description": "实施工作项1按一级 部署方式....",
                        "sii_name": "实施工作项1",
                        "sii_first_workload": "一级部署（总部侧）工作量基数（人天）",
                        "sii_workload": "工作量基数（分部、省公司和直属单位）（人天）",
                        "sii_scope": "实施范围（除总部外）",
                        "sii_workload_total": "初始工作量合计（人天）",
                        "sii_work_scope": "实施工作范围",
                        "sii_application_type": "应用类型",
                        "sii_business_maturity": "业务成熟度",
                        "sii_drl": "灾备等级",
                        "sii_new_technology": "新技术应用",
                        "sii_plats": "感知层业务支撑",
                        "sii_adaptive_adjustment": "适应性调整",
                        "sii_cpc": "跨专业采集",
                        "sii_nft": "非功能性调优",
                        "sii_osc_num": "现场采集数量",
                        "sii_co": "采集对象",
                        "sii_spr": "安全防护要求",
                        "sii_spl": "安全防护等级",
                        "sii_scd": "系统构建难度",
                        "sii_user_active": "用户活跃度",
                        "sii_total": "合计",
                        "sii_work_content": "工作内容",
                        "sii_final_workload": "最终工作量（人天）",
                        "sii_labor_rate": "人工费率（万元/天）",
                        "sii_cost": "系统实施费用（万元）"
                    },
                    {
                        "level": "二级部署",
                        "description": "实施工作项2按二级 部署方式....",
                        "sii_name": "实施工作项1",
                        "sii_second_workload": "二级部署工作量基数（人天））",
                        "sii_scope": "实施范围（除总部外）",
                        "sii_workload_total": "初始工作量合计（人天）",
                        "sii_work_scope": "实施工作范围",
                        "sii_application_type": "应用类型",
                        "sii_business_maturity": "业务成熟度",
                        "sii_drl": "灾备等级",
                        "sii_new_technology": "新技术应用",
                        "sii_plats": "感知层业务支撑",
                        "sii_adaptive_adjustment": "适应性调整",
                        "sii_cpc": "跨专业采集",
                        "sii_nft": "非功能性调优",
                        "sii_osc_num": "现场采集数量",
                        "sii_co": "采集对象",
                        "sii_spr": "安全防护要求",
                        "sii_spl": "安全防护等级",
                        "sii_scd": "系统构建难度",
                        "sii_user_active": "用户活跃度",
                        "sii_total": "合计",
                        "sii_work_content": "工作内容",
                        "sii_final_workload": "最终工作量（人天）",
                        "sii_labor_rate": "人工费率（万元/天）",
                        "sii_cost": "系统实施费用（万元）"
                    }
                ]
            },
            "system_integration_implementation": {
                "si_impl_item": "系统1、系统2、系统3",
                "si_impl_item_num": 3,
                "si_impl_man_day": "人天",
                "si_impl_total": "合计",
                "si_impl_table": [
                    {"no": 1, "system_name": "系统1", "local_man_day": "本端系统集成实施工作量（人天）", "peer_man_day": "对端系统集成实施工作量（人天）"},
                    {"no": 2, "system_name": "系统2", "local_man_day": "本端系统集成实施工作量（人天）", "peer_man_day": "对端系统集成实施工作量（人天）"},
                    {"no": 3, "system_name": "系统3", "local_man_day": "本端系统集成实施工作量（人天）", "peer_man_day": "对端系统集成实施工作量（人天）"}
                ],
                "si_impl_final_workload": "最终工作量（人天）",
                "si_impl_labor_rate": "人工费率（万元/天）",
                "si_impl_cost": "系统功能实施费用（万元）"
            },
            "business_operations": {
                "bo_item": "工作1、工作2",
                "bo_man_day": "人天",
                "bo_total": "合计",
                "bo_table": [
                    {"no": 1, "work_task": "工作任务1", "work_type": "信息支撑及其它", "final_workload": "最终工作量（人天）",
                     "cost": "费用（万元）"},
                    {"no": 2, "work_task": "工作任务2", "work_type": "性能优化", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"}
                ],
                "bo_table_work_total": "最终工作量（人天）合计",
                "bo_table_cost_total": "费用（万元）合计",
                "bo_details_table": [
                    {
                        "bo_work_type": "信息支撑及其它",
                        "bo_workload": "初始工作量（人天）",
                        "bo_scope": "运营范围",
                        "bo_impact_factor": 1,
                        "bo_final_workload": "最终工作量（人天）",
                        "bo_labor_rate": "人工费率（万元/天）",
                        "bo_cost": "业务运营费用（万元）"
                    },
                    {
                        "bo_work_type": "性能优化",
                        "bo_workload": "工作量基数（人天）",
                        "bo_scope": "运营范围",
                        "bo_alc": "架构层次复杂度",
                        "bo_savc": "系统架构版本变化情况",
                        "bo_oscd": "现场协调难度",
                        "bo_oc": "运营规模",
                        "bo_total": "合计",
                        "bo_final_workload": "最终工作量（人天）",
                        "bo_labor_rate": "人工费率（万元/天）",
                        "bo_cost": "业务运营费用（万元）"
                    }
                ]
            },
            "data_engineering": {
                "de_item": "工作1、工作2",
                "de_man_day": "人天",
                "de_total": "合计",
                "de_table": [
                    {"no": 1, "work_task": "工作任务1", "work_type": "信息支撑及其它", "final_workload": "最终工作量（人天）",
                     "cost": "费用（万元）"},
                    {"no": 2, "work_task": "工作任务2", "work_type": "性能优化", "final_workload": "最终工作量（人天）", "cost": "费用（万元）"}
                ],
                "de_table_work_total": "最终工作量（人天）合计",
                "de_table_cost_total": "费用（万元）合计",
                "de_details_table": [
                    {
                        "de_work_task": "工作任务1",
                        "de_work_type": "信息支撑及其它",
                        "de_workload": "工作量基数（人天）",
                        "de_first_num": "一级部署系统数量",
                        "de_second_num": "二级部署系统数量",
                        "de_initial_workload": "初始工作量（人天）",
                        "de_dss": "数据表规模",
                        "de_dtc": "数据类型复杂度",
                        "de_system_type": "系统类型",
                        "de_ambc": "跨多业务口径",
                        "de_pre_results": "前置成果",
                        "de_project_scale": "工程规模",
                        "de_total": "合计",
                        "de_final_workload": "最终工作量（人天）",
                        "de_labor_rate": "人工费率（万元/天）",
                        "de_cost": "业务运营费用（万元）"
                    },
                    {
                        "de_work_task": "工作任务2",
                        "de_work_type": "性能优化",
                        "de_workload": "工作量基数（人天）",
                        "de_first_num": "一级部署系统数量",
                        "de_second_num": "二级部署系统数量",
                        "de_initial_workload": "初始工作量（人天）",
                        "de_ac": "算法复杂度 ",
                        "de_dss": "数据表规模",
                        "de_ambc": "跨多业务口径",
                        "de_dgc": "数据获取复杂度",
                        "de_aef": "应用执行频次",
                        "de_project_scale": "工程规模",
                        "de_fs": "对外服务",
                        "de_lsv": "大屏可视化",
                        "de_final_workload": "最终工作量（人天）",
                        "de_labor_rate": "人工费率（万元/天）",
                        "de_cost": "业务运营费用（万元）"
                    }
                ]
            }
        }
    ]
}


data = {
    "project_name": "集约一体化平台",
    "reporting_unit": "甘肃金诺安电子科技有限公司",
    "date": "2021年3月"
}

data.update(summary.get("calculation_result"))
data.update(preface)
data.update(purpose)
data.update(investment_analysis)
data.update(investment_analysis.get("calculation_result"))
data.update(other_cost)
data.update(items)

# save_docx("xxx", data, "../download/doc/测算报告.docx")
